import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '设备号',
    align: "center",
    dataIndex: 'deviceCode'
  },
  {
    title: '设备名称',
    align: "center",
    dataIndex: 'deviceName'
  },
  {
    title: '设备型号',
    align: "center",
    dataIndex: 'deviceModel'
  },
  {
    title: '设备负责人',
    align: "center",
    dataIndex: 'deviceAdmin'
  },
  {
    title: '设备安装日期',
    align: "center",
    dataIndex: 'deviceInstallTime'
  },
  {
    title: '设备安装位置',
    align: "center",
    dataIndex: 'deviceAddress'
  },
  {
    title: '维保时长(/分)',
    align: "center",
    dataIndex: 'daviceDay', customRender: (text) => {
      let re = ''
      re = text.value
      return re
    }

  },
  // {
  //   title: '上次维保日期',
  //   align: "center",
  //   dataIndex: 'lastTime'
  // },
  // {
  //   title: '下次维保日期',
  //   align: "center",
  //   dataIndex: 'nextTime'
  // },
  // {
  //   title: '设备状态',
  //   align: "center",
  //   dataIndex: 'state',
  //   customRender: (text) => {
  //     let re = ''

  //     if (text.value === 0) {
  //       re = '离线'

  //     } else if (text.value ===1) {
  //       re = '在线'
  //     }else if (text.value ===2) {
  //       re = '报修中'
  //     }else if (text.value ===3) {
  //       re = '维修中'
  //     }else if (text.value ===4) {
  //       re = '维保中'
  //     }
  //     return re
  //   }
  // },
  {
    title: '备注',
    align: "center",
    dataIndex: 'remark'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "设备号",
    field: 'deviceCode',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "设备名称",
    field: 'deviceName',
    component: 'Input',
    colProps: { span: 6 },
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '设备号',
    field: 'deviceCode',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: false },
        { ...rules.duplicateCheckRule('manage_device', 'device_code', model, schema)[0] },
      ];
    },
  },
  {
    label: '设备名称',
    field: 'deviceName',
    component: 'Input',
  },
  {
    label: '设备型号',
    field: 'deviceModel',
    component: 'Input',
  },
  {
    label: '设备负责人',
    field: 'deviceAdmin',
    component: 'Input',
  },
  {
    label: '设备安装日期',
    field: 'deviceInstallTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '设备安装位置',
    field: 'deviceAddress',
    component: 'Input',
  },
  {
    label: '维保周期',
    field: 'daviceDay',
    component: 'InputNumber',
  },
  {
    label: '上次维保日期',
    field: 'lastTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '下次维保日期',
    field: 'nextTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
